precision mediump float;

in vec2 vTextureCoord;

uniform sampler2D uTexture;

uniform float fadeAlpha;
uniform vec4 flashTone;
uniform vec4 tone;

void main(void){
    vec4 base=texture2D(uTexture,vTextureCoord);

    vec3 mixTone=mix(base.rgb,tone.rgb,tone.a);
    float toneAlpha=base.a*(1.0-tone.a)+tone.a;

    vec3 mixFlash=mix(mixTone,flashTone.rgb,flashTone.a);
    float flashAlpha=toneAlpha*(1.0-flashTone.a)+flashTone.a;
    
    float nagFade=1.0-fadeAlpha;
    gl_FragColor=vec4(mixFlash*nagFade,flashAlpha*nagFade+fadeAlpha);
}